<script>
  /*赠品详细通用函数*/

   var priceControl={
              //base:<{$goods.current_price}>,
              _format:<{$money_format|default:'false'}>,
              format:function(num){
                var part;
                if(!num)return;
                var num = num.toFloat();
                    num = num.round(this._format.decimals)+'';
                    var p =num.indexOf('.');
                    if(p<0){
                        p = num.length;
                        part = '';
                    }else{
                        part = num.substr(p+1);
                    }
                    while(part.length<this._format.decimals){
                            part+='0';
                        }
                    var c=[];
                    while(p>0){
                        if(p>2){
                            c.unshift(num.substr(p-=3,3));
                        }else{
                            c.unshift(num.substr(0,p));
                            break;
                        }
                    }
                    if(!part){
                        this._format.dec_point='';
                    }
                    return (this._format.sign||"")+c.join(this._format.thousands_sep)+this._format.dec_point+part;
            }
       };

    String.implement({
      toFormElements:function(){
            if(!this.contains('=')&&!this.contains('&'))return new Element('input',{type:'hidden'});
            var elements=[];
            var queryStringHash=this.split('&');
            $A(queryStringHash).each(function(item){
                if(item.contains('=')){
                    item=$A(item.split('='));
                    elements.push(new Element('input',{type:'hidden',name:item[0],value:item[1]}));
                }else{
                  elements.push(new Element('input',{type:'hidden',name:item}));
                }
            });
            return new Elements(elements);
            }
    });
    Number.implement({
           interzone:function(min,max){
                 var _v=this.toFloat();
                 if(!_v)_v=0;
                 return _v>=min&&_v<=max;
             }
          });
   var keyCodeFix=[48,49,50,51,52,53,54,55,56,57,96,97,98,99,100,101,102,103,104,105,8,9,46,37,39<{if $goods.type.floatstore}>,110,190<{/if}>];


</script>



<div class="GoodsInfoWrap">
<div id="goods-viewer">
  <table width="100%">
  <tr>
    <td valign="top" align="center">
     <div class='goodspic'>
        <{include file="site/product/goodspics.html" app=gift}>
       </div>
    </td>
    <td width="60%" valign="top">
<!------------------------------------ 购买区域 开始 -------------------------------->
<form class="goods-action" action="<{link app=gift ctl='site_gift' act='add_to_cart' arg0='gift'}>" gnotify="<{link app=b2c ctl=site_product act=gnotify}>" method="post"<{if $goods.setting.buytarget==2}> target="_blank_cart"<{elseif $goods.setting.buytarget==3}> target="_dialog_minicart"<{/if}>>

    <h1 class="goodsname"><{$gift.name|escape:"html"}></h1>
    <{if $gift.brief}>
    <p class="brief"><{$gift.brief}></p>
    <{/if}>

    <{assign var=tmp value=$goods.product}>
    <{assign var=product0bn value=$tmp|array_shift}>
      <ul class="goodsprops clearfix">
        <{if $goods.bn && $goodsBnShow != 'false'}><li><span><{t}>赠品编号：<{/t}></span><{$goods.bn}></li><{/if}>
        <{if $goods.product_bn || $product0bn.bn}><li><span><{t}>货号：<{/t}></span><span id="goodsBn"><{if $goods.product_bn}><{$goods.product_bn}><{else}><{$product0bn.bn}><{/if}></span></li><{/if}>
        <li><span><{t}>赠品分类：<{/t}></span><{$gift.cat.cat_name}></li>
        <{if $goods.weight && $goods.weight != 0.000 }><li><span><{t}>赠品重量：<{/t}></span><span id="goodsWeight"><{if $goods.weight}><{$goods.weight}><{else}><{$goods.weight.0.bn}><{/if}></span><{t}> 克(g)<{/t}></li><{/if}>
        <{if $goods.price && $goods.price != 0.00 }><li><span><{t}>赠品价格：<{/t}></span><span id="goodsWeight"><{$goods.price|cur}></span></li><{/if}>
        <li><span><{t}>兑换起始时间：<{/t}></span><{$gift.from_time|userdate}></li>
        <{if $goods.store}><li><span><{t}>库存数量：<{/t}></span><{$goods.store}></li><{/if}>
        <li><span><{t}>兑换截止时间：<{/t}></span><{$gift.to_time|userdate}></li>
        <li><span><{t}>数量限制：<{/t}></span><{if empty($gift.max_buy_store) && $gift.max_buy_store!==0}><{t}>无数量限制<{/t}><{else}><{$gift.max_buy_store}><{/if}></li>
        <li ><span><{t}>兑换所需积分：<{/t}></span><{$gift.consume_score}></li>
        <li class="spec" style="white-space:normal;"><span><{t}>兑换级别：<{/t}></span>
           <{if is_array($member_lv)}>
             <{foreach from=$member_lv item=level}><{$level.name}>&nbsp;&nbsp;<{/foreach}>
           <{else}>
             <{t}>无<{/t}>
           <{/if}>
        </li>
     
     
     
     </ul>


<{if $gift.marketable == 'false' }>
 <!---已下架--->
<div class="hight-offline">
    <div class="hightbox">
        <div class="btnBar clearfix">
            <div class="floatLeft" style="font-weight:bold; padding-top:15px;"><{t}>此赠品已下架<{/t}></div>
        </div>
    </div>
</div>

<{else}>
 <!---购物面板--->
 <div class='hightline'>
 <div class='hightbox'>
 <!---规格开始--->
<{if $goods.spec }>
<{include file='site/product/spec.html' app=gift}>
<{/if}>
<!---规格结束--->

<!--购买数量-->
         <div class='buyinfo'>
         <table width='auto'>
            <tr>
               <td><span><{t}>购买数量：<{/t}></span></td>
               <td><div class="Numinput">
                    <input type="text" name="goods[num]" size="5" value=1 />
                    <span  class="numadjust increase"></span>
                    <span  class="numadjust decrease"></span>
                    </div>
                    <td><{if $goods.package_unit}><{$goods.package_unit}><{t}>(每<{/t}><{$goods.package_scale}><{t}>个一<{/t}><{$goods.package_unit}>)<{/if}></td>
               </td>
               <td>
               </td>
               <td><span <{if $showStorage != 'true'}>style='display:none;'<{/if}>><{t}>&nbsp;&nbsp;(库存<{/t}><span class='store'><{if $goods.store >= 9999 || $goods.store == null || $goods.store === ''}>9999+<{else}><{$goods.store - $goods.product_freez}><{/if}></span>)</span></td>
            </tr>
         </table>
         </div>
<!--购买数量结束-->
<!------------------------------------ 购买 按钮 -------------------------------->

<input type="hidden" name="goods[goods_id]" value="<{$goods.goods_id}>" />
<input type="hidden" name="goods[pmt_id]" value="<{$goods.pmt_id}>" />
<{if !$goods.spec }>
<input type='hidden' name='goods[product_id]' value='<{$product0bn.product_id}>'/>
<{/if}>

<{if $site_point_usage == '1'}>
<div class="btnBar clearfix" <{if count($goods.product)<0}>style="visibility:hidden"<{/if}>>

  <div class="floatLeft">
        <{if count($goods.product)>1}>
           <{if $env.conf.b2c.system.goods.fastbuy=='true'}>

           <{/if}>
            <input class="actbtn btn-buy" value="<{t}>加入购物车<{/t}>" type="submit" />
            <!--<input  class="actbtn btn-notify" value="<{t}>缺货登记<{/t}>" type="submit" style="display: none;" />-->
        <{else}>
            <{if $goods.store>0 || $goods.store==''}>
                <input class="actbtn btn-buy" value="<{t}>加入购物车<{/t}>" type="submit" />
            <{else}>
                <!--<input  class="actbtn btn-notify" value="<{t}>缺货登记<{/t}>" type="submit" />-->
            <{/if}>
        <{/if}>
    </div>
</div>
<{/if}>
<!--购买按钮结束-->
    </div><!-- end hightbox-->
  </div><!-- end hightline-->



<{/if}>



</form>

    </td>
  </tr>

  </table>



<!--货品列表-->
<{if $goods.spec}>
<{include file='site/product/products.html' app=gift}>
<{/if}>
<div style="clear:both"></div>
<!------------------------------------ 购买区域 结束 -------------------------------->
<!-- 原捆绑赠品 -->


<{if $goods.description}>
<div class="body indent uarea-output" id="goods-intro">
<{$goods.description}>
</div>
<{/if}>




<{if $comment.switch.ask == 'on' && $comment.askCount>0 }>
<div class="section pdtdetail" tab="<{t}>购买咨询<{/t}>(<em><{$comment.askCount|default:'0'}></em>)">

<div class="commentTabLeft floatLeft"><strong><{t}>购买咨询<{/t}></strong><span><a href="<{link app=b2c ctl="site_comment" act="commentlist" arg0=$goods.goods_id arg1="ask"}>"><{t}>（已有<{/t}><{$comment.askCount|default:'0'}><{t}>条咨询）<{/t}></a></span></div>
<div class="floatLeft commentTabRight"></div>
<div style="clear:both;"></div>
<div class="FormWrap" style="background:#f6f6f6; margin-top:0px;">
<{if count($comment.list.ask) == 0}>
<div class="boxBlue division">
<{$comment.null_notice.ask}>
</div>
<{else}>
<div class=" Comments" id="goods-comment">
<{foreach from=$comment.list.ask item=comlist name=asklist}>
  <div class="division boxBlue clearfix" style="margin-bottom:0px;">
    <div class=" floatLeft commentMain">
     <div class="floatLeft commentAsk"><{t}>提问<{/t}></div>
     <span class="author fontcolorOrange"><{$comlist.author}><!--<{if $comlist.levelname!=""}> [<{$comlist.levelname}>]<{/if}> --></span> <{t}>说：<{/t}>
     <span class="timpstamp font10px fontcolorGray"><{$comlist.time|cdate:'SDATE_STIME'}></span>
     <div  style="clear:both;"></div>
     <div class="commentText"><{$comlist.comment|nl2br}></div>
    </div>
    <div class="floatRight"><a class="floatRight lnk " href="<{link app=b2c ctl="site_comment" act="reply" arg0=$comlist.comment_id}>" arg1="ask"><{t}>查看或回复此评论<{/t}></a></div>
   </div>
   <div class="commentReply">
    <{foreach from=$comlist.items item=items}>
        <div class="division  item " style=" margin:0px;" >
        <div class="floatLeft commentReply-admin"><{t}>回答<{/t}></div>
        <span class="author fontcolorOrange"><{$items.author}><!--<{if $items.levelname!=""}> [<{$items.levelname}>]<{/if}> --></span>&nbsp;&nbsp;<{t}>回复：<{/t}>
        <span class="timpstamp font10px fontcolorGray"><{$items.time|cdate:'SDATE_STIME'}></span>
        <div  style="clear:both;"></div>
        <div class="commentText"><{$items.comment|nl2br}></div>
        </div>
     <{/foreach}>
   </div>
<{/foreach}>
</div>
<div class="textright"><a href="<{link app="b2c" ctl="site_comment" act="commentlist" arg0=$goods.goods_id arg1="ask"}>"><{t}>查看所有咨询&gt;&gt;<{/t}></a></div>
<{/if}>
<!--
<form class="addcomment" method="post" action='<{link app=b2c ctl="site_comment" act="toComment" arg0=$goods.goods_id arg1="ask"}>' onsubmit='checkFormReqs(event);'>
  <h4><{t}>发表咨询<{/t}></h4>
  <div class='title'><{t}>标题：<{/t}><{input type="text" class="inputstyle blur"  required="true" size=50 name="title" value="[咨询]".$goods.name }></div>
  <div class="division">
      <table border="0" width="100%" cellpadding="0" cellspacing="0" class="forform">
            <tr>
            <th><em>*</em><{t}>咨询内容：<{/t}></th>
              <td><{input type="textarea" class="inputstyle"  vtype="required" rows="5" name="comment" style="width:80%;"}></td>
            </tr>
            <tr>
            <{if $login eq "nologin"}>
           <tr>
           <th><{t}>联系方式：<{/t}></th>
                <td><{input type="text" class="inputstyle"   size=20 name="contact"}><span class="infotips"><{t}>(可以是电话、email、qq等)<{/t}></span></td>
            </tr>
            <{/if}>
            <{if $askshow == "on"}>
            <th><em>*</em><{t}>验证码：<{/t}></th>
              <td><{input type="number" required="true" size="4" maxlength="4" name="askverifyCode"}>&nbsp;<img src="<{link app="b2c" ctl="site_comment" act="gen_askvcode" arg0=$smarty.now}>" border="1" id="askimgVerifyCode"/><a href="javascript:changeimg('askimgVerifyCode','ask')"><{t}>&nbsp;看不清楚?换个图片<{/t}></a></td>

            </tr>
            <{/if}>

            <tr>
            <td></td>
              <td><input type="submit" value="<{t}>提交咨询<{/t}>"></td>
            </tr>
        </table>
  </div>
</form>
-->
</div>
</div>
<{/if}>

<{if $comment.switch.discuss == 'on' && $comment.discussCount>0 }>
<div class="section pdtdetail" tab="<{t}>赠品评论<{/t}> (<em><{$comment.discussCount|default:'0'}></em>)">
<div class="commentTabLeft floatLeft"><strong><{t}>赠品评论<{/t}></strong><span><a href="<{link app=b2c ctl="site_comment" act="commentlist" arg0=$goods.goods_id arg1="discuss"}>"><{t}>（已有<{/t}><em><{$comment.discussCount|default:'0'}></em><{t}>条评论）<{/t}></a></span></div>
<div class="commentTabRight floatLeft"></div>
<div style="clear:both;"></div>
<div class="FormWrap" style="background:#f6f6f6; margin-top:0px;">
<{if count($comment.list.discuss) == 0}>
<div class="boxBrown division">
<{$comment.null_notice.discuss}>
</div>
<{else}>
<div class=" Comments" id="goods-comment">
<{foreach from=$comment.list.discuss item=comlist name=discusslist}>



  <div class="division boxBlue clearfix" style="margin-bottom:0px;">
    <div class=" floatLeft commentMain">
     <div class="floatLeft commentAsk"><{t}>提问<{/t}></div>
   <span class="author fontcolorOrange"><{$comlist.author}><!--<{if $comlist.levelname!=""}> [<{$comlist.levelname}>]<{/if}> --></span><{t}>说：<{/t}><{/t}>
    <span class="timpstamp font10px fontcolorGray replies prepend-1"><{$comlist.time|cdate:'SDATE_STIME'}></span>
 <div  style="clear:both;"></div>


  <div class="commentText"><{$comlist.comment|nl2br}></div>
    </div>

<div class="floatRight"><a class="floatRight lnk " href="<{link app=b2c ctl="site_comment" act="reply" arg0=$comlist.comment_id}>" arg1="ask"><{t}>查看或回复此评论<{/t}></a></div>
 </div>

     <div class="commentReply">
    <{foreach from=$comlist.items item=items}>
      <div class="division  item " style=" margin:0px;" >
        <div class="floatLeft commentReply-admin"><{t}>回复<{/t}></div>
    <span class="author fontcolorOrange"><{$items.author}><!--<{if $items.levelname!=""}> [<{$items.levelname}>]<{/if}> --><{t}></span>&nbsp;&nbsp;回复：<{/t}>
    <span class="timpstamp font10px fontcolorGray replies prepend-1"><{$items.time|cdate:'SDATE_STIME'}></span>
    <div  style="clear:both;"></div>
    <div class="commentText"><{$items.comment|nl2br}></div>
    </div>
 <{/foreach}>
 </div>



<{/foreach}>
</div>

    <div class="textright"><a href="<{link app=b2c ctl="site_comment" act="commentlist" arg0=$goods.goods_id arg1="discuss"}>"><{t}>查看所有评论&gt;&gt;<{/t}></a></div>
    <{/if}>
    <!--
    <form class="addcomment" method="post" action='<{link app=b2c ctl="site_comment" act="toComment" arg0=$goods.goods_id arg1="discuss"}>' onsubmit='checkFormReqs(event);'>
      <h4><{t}>发表评论<{/t}></h4>
      <div class='title'><{t}>标题：<{/t}><{input type="text" class="inputstyle blur"  required="true" size=50 name="title" value="[评论]".$goods.name}></div>
      <div class="division">
          <table border="0" cellpadding="0" cellspacing="0" width="100%" class="forform">

                <tr>
                <th><em>*</em><{t}>评论内容：<{/t}></th>
                  <td><{input type="textarea" class="x-input inputstyle"  vtype="required" rows="5" name="comment" style="width:80%;"}></td>
            </tr>
                <{if $login eq "nologin"}>
               <tr>
                <th><{t}>联系方式：<{/t}></th>
                    <td><{input type="text" class="inputstyle"  size=20 name="contact"}><span class="infotips"><{t}>(可以是电话、email、qq等).<{/t}></span></td>
                </tr>
                <{/if}>
               <{if $discussshow == "on"}>
                <tr>
                <th><em>*</em><{t}>验证码：<{/t}></th>
                    <td><{input type="number" required="true" size="4" maxlength="4" name="discussverifyCode"}>&nbsp;<img src="<{link app="b2c" ctl="site_comment" act="gen_dissvcode" arg0=$smarty.now}>" border="1" id="discussimgVerifyCode"/><a href="javascript:changeimg('discussimgVerifyCode','discuss')"><{t}>&nbsp;看不清楚?换个图片<{/t}></a>

                    </td>
                </tr>
                <{/if}>

                <tr>
                <td></td>
                  <td><input type="submit" value="<{t}>提交评论<{/t}>"></td>
                </tr>
            </table>
      </div>
    </form>
    -->
</div>
</div>
<{/if}>

<div id='template-modal' style='display:none;'> <div class='dialog'> <div class='dialog-title clearfix'> <div class='title span-auto'>{title}</div> <div class='dialog-close-btn' onclick='$(this).getParent(".dialog").remove();'>X</div> </div> <div class='dialog-content'> {content} </div> </div> </div>




<script>
<{if $comment.switch.ask == 'on' or $comment.switch.discuss == 'on'}>

    var checkFormReqs =function(e){
           e    = new Event(e);
       var _form= $(e.target);

       var reqs = $$(_form.getElements('input[type=text]'),_form.getElements('textarea'));


       if(reqs.some(function(req){
            if(!req.get('required')&&!req.get('vtype').contains('required'))return;
            if(req.getValue().trim()==''){
                       req.focus();
                       MessageBox.error('<{t}>请完善表单必填项<{/t}><sup>*</sup>');
                       return true;
            }

              return false;


       })){

           e.stop();

       }

    };

    function changeimg(){ 
        $('discussimgVerifyCode').set('src','<{link app="b2c" ctl="site_comment" act="gen_dissvcode" }>?'+$time());
    }
    
    
    
</script>
<{/if}>

<script>
var Shop = {
    url:{diff:''}
}
</script>


</div>

</div>

<{include file='site/product/goods_js.html' app=b2c}>